package com.github.livebase.event;

import com.github.livebase.util.base.Assert;

/**
 * @ClassName RegistrableListener
 * @description:
 * @author: biao532
 * @create: 2024-02-02 10:05
 * @Version 1.0
 **/
public abstract class RegistrableListener implements EventListener{
    private String eventId;
    protected RegistrableListener(String eventId, boolean async) {
        Assert.hasLength(eventId, "eventId not be null or empty");
        this.eventId = eventId;
        SimpleEventBus.getDefault().register(eventId,this, async);
    }

    public void unregister() {
        SimpleEventBus.getDefault().unregister(eventId, this);
    }
}
